package interviewpreparationkit.sorting


import redirectSystemIn
import redirectSystemOut
import org.junit.jupiter.api.Test
import java.util.*

class CountInversionsTests {
    @Test
    fun countInversionsTests() {
        redirectSystemIn(this.javaClass) {
            val scan = Scanner(System.`in`)
            redirectSystemOut {
                while (scan.hasNextLine()) {
                    val t = scan.nextLine().trim().toInt()

                    for (tItr in 1..t) {
                        val n = scan.nextLine().trim().toInt()
                        val arr = scan.nextLine().split(" ").map { it.trim().toInt() }.toTypedArray()
                        val result = countInversions(arr)

                        println(result)
                    }
                    for (tItr in 1..t) {
                        it.add(scan.nextLine().trim())
                    }
                }
            }
        }
    }
}